package com.demo.reg.service;

import com.demo.common.model.User;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.plugin.activerecord.tx.Tx;

public class RegService {
    /**
     * 用户表
     */
    @Inject
    public User userDao;

    /**
     * 用户注册
     */
    @Before(Tx.class)
    public boolean createUser(User user){
        try{
            User userByLN = userDao.getUserByLN(user.getLoginname());
            if(null!=userByLN){
                return false;
            }else{
                return userDao.addUser(user);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return false;
    }
    public User getUserByLN(String loginname){
        return userDao.getUserByLN(loginname);
    }
}
